/*
 * Copyright (c) 2018.
 * By:kaihangchen
 * E-mail:cmxds@hotmail.com
 */

package cn.cmxds.store.view.Impl.activity;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.GridView;
import android.widget.LinearLayout;

import com.zhhr.custom.ZToast;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.cmxds.store.R;
import cn.cmxds.store.application.CustomApplcation;
import cn.cmxds.store.presenter.IGoodsTypePresenter;
import cn.cmxds.store.presenter.Impl.GoodsTypePresenter;
import cn.cmxds.store.util.ToastFactory;
import cn.cmxds.store.view.IGoodsTypeView;
import cn.cmxds.store.widget.ActionSheetDialog;
import cn.cmxds.store.widget.ActionSheetDialog.SheetItemColor;
import cn.cmxds.store.widget.MyToolBar;

public class GoodsTypeActivity extends BaseActivity implements IGoodsTypeView {
    @BindView(R.id.act_goods_type_gv)
    GridView mActGoodsTypeGv;
    @BindView(R.id.act_goods_type_ln_content)
    LinearLayout mActGoodsTypeLnContent;
    @BindView(R.id.toolbar)
    MyToolBar toolbar;
    private IGoodsTypePresenter presenter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.goods_type);
        ButterKnife.bind(this);
        new GoodsTypePresenter(this);
        presenter.initData();
    }

    @Override
    public void showMsg(String msg) {
        ZToast.init(Color.parseColor("#eb4f38"),Color.parseColor("#ffffff"),false,0,55);
        ZToast.makeText(getParent(),msg,1000).show();
//        ToastFactory.getToast(this, msg).show();
    }

    @Override
    public void showLoadingDialog(String title, String msg, boolean flag) {
        super.showProcessDialog(title, msg, flag);
    }

    @Override
    public void canelLoadingDialog() {
        super.dismissProcessDialog();
    }

    @Override
    public void jumpActivity(String datas) {
        //跳转到商品展示的页面
        Intent intent = new Intent(this, GoodsResultActivity.class);
        intent.putExtra("datas", datas);
        startActivity(intent);
    }
    @OnClick({R.id.toolbar_left_button,R.id.toolbar_right_button})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.toolbar_left_button:
                finish();
                break;
            case R.id.toolbar_right_button:
//                showMsg("菜单被按下");
//                必须使用Activity.this
                new ActionSheetDialog(GoodsTypeActivity.this) .builder() .setTitle("返回键不可退出外部可点击") .setCancelable(false) .setCanceledOnTouchOutside(true)
                        .addSheetItem("条目一", SheetItemColor.Blue, new ActionSheetDialog.OnSheetItemClickListener() {
                    @Override public void onClick(int which) { finish();} })
                        .addSheetItem("条目二",SheetItemColor.Blue, new ActionSheetDialog.OnSheetItemClickListener() {
                    @Override public void onClick(int which) { finish();} })
                        .addSheetItem("条目三", SheetItemColor.Blue, new ActionSheetDialog.OnSheetItemClickListener() {
                    @Override public void onClick(int which) { finish();} })
                        .addSheetItem("条目四", SheetItemColor.Blue, new ActionSheetDialog.OnSheetItemClickListener() {
                    @Override public void onClick(int which) { finish();} })
                        .show();
                break;

        }
    }

    @Override
    public void setPresenter(IGoodsTypePresenter presenter) {
        this.presenter = presenter;
    }

    @Override
    public GridView getmActGoodsTypeGv() {
        return mActGoodsTypeGv;
    }

    @Override
    public LinearLayout getmActGoodsTypeLnContent() {
        return mActGoodsTypeLnContent;
    }


}
